package com.xiaomi.service.Impl;


import com.xiaomi.dao.CpMapper;
import com.xiaomi.dao.CpfenleiMapper;
import com.xiaomi.dao.CpguigeMapper;
import com.xiaomi.dao.ZhongleiMapper;
import com.xiaomi.entity.Cp;
import com.xiaomi.service.CpService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @ClassName CpServicelmpl
 * @Description TODO
 * @Author HP
 * @Date 2021/11/28 20:16
 */
@Service
public class CpServicelmpl implements CpService {

    @Resource
    CpMapper cpMapper;
    @Resource
    CpfenleiMapper cpfenleiMapper;
    @Resource
    ZhongleiMapper zhongleiMapper;
    @Resource
    CpguigeMapper cpguigeMapper;

    @Override
    public List<Cp> selectAll(Map<String, Object> pars) {
      List<Cp> cpList=cpMapper.selectAll(pars);

      for (Cp cp:cpList){
          cp.setCpfenleiList(cpfenleiMapper.selectByCpfenleiid(cp.getCpfenleiid()));
          cp.setZhongleiList(zhongleiMapper.selectByZhongleiid(cp.getCpzhongleiid()));
          cp.setCpguige(cpguigeMapper.selectByCpguige(cp.getCpguigeid()));
      }
      return cpList;
    }

    @Override
    public int count(Map<String, Object> pars) {
        return cpMapper.count(pars);
    }

    @Override
    public int add(Cp cp) {
        return cpMapper.add(cp);
    }

    @Override
    public int del(int id) {
        return cpMapper.del(id);
    }

    @Override
    public int update(Cp cp) {
        return cpMapper.update(cp);
    }
}